var cheerio = require('cheerio');
var request = require('request');
var iconv = require('iconv-lite');
var BufferHelper = require('bufferhelper');
var fs = require("fs");
var DataSet = require('./dataSet.js');

var getLesson = function(param) {
  var defaultOptions = {
    protocol: 'http:',
    host: '210.42.121.132',
    pathname: "",
    query: "",
    cookie: "",
    thread: 10,
  };
  var options = param.options;
  if (!options) {
    throw new Error("没有传入参数");
  }
  //option 检测

  var url = function() {
    return options.protocol + "//" + options.host + options.pathname +
      "?" + (options.query ? options.query + "&" : "");
  }();

  var requestOptions = {
    method: 'get',
    headers: {
      'Cookie': options.cookie,
      'Connection': 'keep-alive'
    }
  }

  var getUrl = function(page) {
    return url + "pageNum" + (page ? page : 1);
  }

  var pool;
  var instance = function() {
    this.name = "";
  };
  instance.prototype.start = function() {

  };
  instance.prototype.abort = function() {

  }
  return instance;
}

/**
 * hooks
 * create()
 * onError()
 * onAnalyse(只需要分析case即可)
 */

function requestPool(param) {
  this._init(param)
}
requestPool.prototype = {
  _init: function(param) {
    this.thread = param.thread || 10;
    this.taskCount = 0;
    this.pool = [];
  },
  push: function(fun) {
    this.pool.push(fun);
  },
  next: function(){

  }
}
